package com.guli.oss.controller;

import com.guli.common.result.R;
import com.guli.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(description="阿里云文件管理")
@RestController
@RequestMapping("/admin/oss/file")
@CrossOrigin
public class FileUploadController {

    @Autowired
    private FileService fileService ;

    @ApiOperation(value = "上传文件")
    @PostMapping("upload")
    public R uploadImage(@RequestParam("file")  MultipartFile file ){

        String uploadUrl = fileService.upload(file);
        //返回r对象
        return R.ok().message("文件上传成功").data("url", uploadUrl);
    }

}
